package com.wxw.BaseLibrary.component;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.wxw.BaseLibrary.R;
import com.wxw.BaseLibrary.drawable.PanelStyle;

/**
 * Created by david on 2014-06-05.
 */
public class DragListItemView extends LinearLayout{
    public TextView getTextView() {
        return textView;
    }

    public ImageView getImageView() {
        return imageView;
    }

    public TextView getTvIndex(){
        return tvIndex;
    }

    private TextView textView;
    private TextView tvIndex;
    private ImageView imageView;

    public DragListItemView(Context context) {
        super(context);
        setOrientation(HORIZONTAL);
//        ((LinearLayout.LayoutParams)getLayoutParams()).setMargins(10, 10, 10, 10);
        setGravity(Gravity.CENTER);
        setBackground(PanelStyle.createPanelStyle(GradientDrawable.Orientation.TOP_BOTTOM, new int[]{Color.parseColor("#fffffdf8"), Color.parseColor("#ffe3e3e3")}, 1, Color.parseColor("#505050"), 0));

        tvIndex = new TextView(context);
        LayoutParams layoutParams1 = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
        layoutParams1.setMargins(5, 5, 5, 5);
        tvIndex.setLayoutParams(layoutParams1);
        tvIndex.setBackgroundColor(Color.TRANSPARENT);
        tvIndex.setTextColor(Color.RED);
        tvIndex.setGravity(Gravity.CENTER);
        tvIndex.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
        addView(tvIndex);

        textView = new TextView(context);
        LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
        layoutParams.setMargins(5, 5, 5, 5);
        layoutParams.weight = 1;
        textView.setLayoutParams(layoutParams);
        textView.setBackgroundColor(Color.TRANSPARENT);
        textView.setTextColor(Color.BLACK);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
        addView(textView);

        imageView = new ImageView(context);
        imageView.setImageResource(R.drawable.list_drag_icon);
        imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        addView(imageView);
    }
}
